package edu.sctu.practice.class01.nieyu.test.test03;

/**
 * Created by Administrator on 2015/10/14.
 */
public class Number {
    //定义名为Number的类，其中有两个整型数据成员n1和n2，应声明为私有。

    private int n1;
    private int n2;

    public Number(int n1, int n2) {

        this.n1 = n1;
        this.n2 = n2;

    }

    public int addition() {

        int sum = n1 + n2;//sum为两数和
        return sum;

    }

    public int subtration() {

        int sub;//sub为两数差

        if (n1 > n2) {
            sub = n1 - n2;
        } else {
            sub = n2 - n1;
        }

        return sub;
    }

    public int multiplication() {

        int mul = n1 * n2;//mul为两数积；

        return mul;
    }

    public void division() {

        if (n1 != 0) {
            int div = n2 / n1;//div为两数商
            System.out.println(div);
        } else if (n2 != 0) {
            int div = n1 / n2;
            System.out.println(div);
        } else {
            System.out.println("输入的数字有误，请重新输入！！");
        }

    }
}
